package com.slipper.ai.model.chat;

import com.slipper.ai.model.chat.support.*;
import com.slipper.exception.CommonException;
import com.slipper.system.ai.bo.AiModelBO;
import org.springframework.ai.chat.model.ChatModel;

import java.util.HashMap;
import java.util.Map;

public class ChatModelFactory {
    private static final Map<String, ChatModelBuilder> builderMap = new HashMap<>() {{
        put("deepseek", new DeepSeekChatModelBuilder());
        put("ollama", new OllamaChatModelBuilder());
        put("zhipuai", new ZhipuaiChatModelBuilder());
        put("openai", new OpenAiChatModelBuilder());
        put("qianfan", new QianFanChatModelBuilder());
        put("dashscope", new DashScopeChatModelBuilder());
    }};

    public static ChatModel create(AiModelBO model) {
        ChatModelBuilder builder = builderMap.get(model.getSupplierCode());
        if (builder == null) {
            throw new CommonException("不支持此供应商标识[" + model.getSupplierCode() + "]不存在！");
        }
        return builder.build(model);
    }
}
